package demo1;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-10-24
 * Time：21:52
 */
public class TestDemo {
    public static void main(String[] args) {
        String s = "0P";
        s = s.toLowerCase();
        int left = 0;
        int right = s.length() - 1;
        while(left < right) {
            char leftValue = s.charAt(left);
            char rightValue = s.charAt(right);
            while (!((leftValue >= 'a' && leftValue <= 'z') || (leftValue >= '0' && leftValue <= '9'))
                    && left < right) {
                left++;
                leftValue = s.charAt(left);
            }
            while (!((rightValue >= 'a' && rightValue <= 'z') || (rightValue >= '0' && rightValue <= '9'))
                    && left < right) {
                right--;
                rightValue = s.charAt(right);
            }
            if (leftValue != rightValue) {
                System.out.println(false);
                break;
            }
            left++;
            right--;
        }
        if(left >= right) {
            System.out.println(true);
        }

    }
    public static void main2(String[] args) {
        String s = new String("hello nowcoder       ");
        String tmp = s.trim();
        int index1 = tmp.lastIndexOf(' ');
        System.out.println(tmp.length() - 1 - index1);
    }
    public static void main1(String[] args) {
        //可变的，不用创建新的对象去接收
        //1.线程安全的
        StringBuffer stringBuffer = new StringBuffer("hello");
        stringBuffer.append("!!!!").append("9999");
        stringBuffer.insert(0,"cs ");
        System.out.println(stringBuffer);
        //2.不是线程安全的
        StringBuilder stringBuilder = new StringBuilder("hello");
        stringBuffer.append(" world");
    }
}
